    //
//  ItemDetailController.m
//  123
//
//  Created by Wang Jun on 11-8-7.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "ItemDetailController.h"


@implementation ItemDetailController

// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/


// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
	
	CGRect applicationFrame = [UIScreen mainScreen].applicationFrame;
	
	self.view = [[[UIView alloc] initWithFrame:applicationFrame] autorelease];
	self.view.backgroundColor = TTSTYLEVAR(tabTintColor);
	
	_tabBar = [[TTTabBar alloc] initWithFrame:CGRectMake(0, 0 , applicationFrame.size.width, 40)];
	_tabBar.tabItems = [NSArray arrayWithObjects:
						 [[[TTTabItem alloc] initWithTitle:@"概述"] autorelease],
						 [[[TTTabItem alloc] initWithTitle:@"特点"] autorelease],
						 [[[TTTabItem alloc] initWithTitle:@"点评"] autorelease],
						 [[[TTTabItem alloc] initWithTitle:@"地图"] autorelease],
						 nil];
	_tabBar.contentMode = UIViewContentModeScaleToFill;
	_tabBar.delegate = self;
	_tabBar.selectedTabIndex = 2;
	[self.view addSubview:_tabBar];
	
	
	
}



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[_tabBar release];
	[_detailView release];
    [super dealloc];
}
- (void)tabBar:(TTTabBar*)tabBar tabSelected:(NSInteger)selectedIndex{
	
	NSString *message = [[NSString alloc] initWithFormat:@"you selected %d",selectedIndex,nil];

	
	if (_detailView == nil) {
		NSLog(@"init");
		CGRect applicationFrame = [UIScreen mainScreen].applicationFrame;
		
		_detailView = [[UIView alloc] initWithFrame:CGRectMake(0, 40 , applicationFrame.size.width, 40)];
		UILabel *label = [[UILabel alloc]  initWithFrame:CGRectMake(0,0, applicationFrame.size.width, 40)];
		[label setText:message];
		[_detailView addSubview:label];
		[self.view addSubview:_detailView];
		[label release];
		
		
	}else {
		
		UILabel * label = [[_detailView subviews] objectAtIndex:0];
		[label setText:message];
		
	}
	[message release];
	
	
}


@end
